{
  This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.
   
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
}

// Copyright (c) 2010 2011 2012 - J. Aldo G. de Freitas Junior

{$mode objfpc}
{$H+}{$M+}

Unit
	Nodes;

Interface

Uses
	Classes,
	SysUtils,
	StrUtils,
	Tree,
	XMLNodes,
	XMLLoader;

Type
	TDataBaseNode = Class(TXMLRootNode)
	Public
		Constructor Create(Const aOWner : TTreeNode); Override;
		Procedure SaveToFile(Const aFileName : String);
		Class Function RegisteredName : String; Override;
	End;

// Interface related

	TInterfacesNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	THardwareInterfaceNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
		Procedure OnUpdate(Var Message); Message 'update';
	End;
	
	THardwareInterfaceNodeEntry = Class(TXMLNode)
	Private
		fName : String;
		fRecvBytes,
		fSentBytes,
		fRecvPackets,
		fSentPackets,
		fRecvErr,
		fSentErr,
		fRecvDrop,
		fSentDrop,
		fRecvFifo,
		fSentFifo,
		fRecvFrame,
		fSentFrame,
		fRecvCompressed,
		fSentCompressed,
		fRecvMulticast,
		fSentMulticast : Integer;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
		Property RecvBytes : Integer Read fRecvBytes Write fRecvBytes;
		Property SendBytes : Integer Read fSentBytes Write fSentBytes;
		Property RecvPackets : Integer Read fRecvPackets Write fRecvPackets;
		Property SendPackets : Integer Read fSentPackets Write fSentPackets;
		Property RecvErrors : Integer Read fRecvErr Write fRecvErr;
		Property SendErrors : Integer Read fSentErr Write fSentErr;
		Property RecvDrop : Integer Read fRecvDrop Write fRecvDrop;
		Property SendDrop : Integer Read fSentDrop Write fSentDrop;
		Property RecvFIFO : Integer Read fRecvFifo Write fRecvFifo;
		Property SendFIFO : Integer Read fSentFifo Write fSentFifo;
		Property RecvFrame : Integer Read fRecvFrame Write fRecvFrame;
		Property SendFrame : Integer Read fSentFrame Write fSentFrame;
		Property RecvCompressed : Integer Read fRecvCompressed Write fRecvCompressed;
		Property SendCompressed : Integer Read fSentCompressed Write fSentCompressed;
		Property RecvMulticast : Integer Read fRecvMulticast Write fRecvMulticast;
		Property SendMulticast : Integer Read fSentMulticast Write fSentMulticast;
	End;
	
	TSoftwareInterfaceNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TDHCPInterfaceNode = Class(TXMLNode)
	Private
		fName,
		fRelated : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
		Property Related : String Read fRelated Write fRelated;
	End;
	
	TFixedIPInterfaceNode = Class(TXMLNode)
	Private
		fName,
		fRelated,
		fIP,
		fNetMask : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
		Property Related : String Read fRelated Write fRelated;
		Property IP : String Read fIP Write fIP;
		Property Netmask : String Read fNetmask Write fNetmask;
	End;

// System and script related

	TScriptsNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TScriptEntryNode = Class(TXMLNode)
	Private
		fName : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
	End;
	
	TSystemNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TEditorNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;

// Services related
	
	TServicesNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TServiceEntryNode = Class(TXMLNode)
	Private
		fName,
		fOnStart,
		fOnStop,
		fOnRestart : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
		Property OnStart : String Read fOnStart Write fOnStart;
		Property OnStop : String Read fOnStop Write fOnStop;
		Property OnRestart : String Read fOnRestart Write fOnRestart;
	End;

// Template related	

	TTemplatesNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TTemplateEntryNode = Class(TXMLNode)
	Private
		fName,
		fSource,
		fDestination,
		fCurrentHash,
		fLastHash : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Name : String Read fName Write fName;
		Property Source : String Read fSource Write fSource;
		Property Destination : String Read fDestination Write fDestination;
		Property CurrentHash : String Read fCurrentHash Write fCurrentHash;
		Property LastHash : String Read fLastHash Write fLastHash;
	End;
	
	TTemplateEffectsNode = Class(TXMLNode)
	Private
		fService : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Service : String Read fService Write fService;
	End;

// Cache related
	
	TCacheNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;
	
	TConfigCacheNode = Class(TXMLNode)
	Private
		fIP,
		fHostname : String;
		fPort,
		fMemSize,
		fDiskSize,
		fMaxMemObjSize,
		fMaxDiskObjSize : Integer;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property IP : String Read fIP Write fIP;
		Property Hostname : String Read fHostname Write fHostname;
		Property Port : Integer Read fPort Write fPort;
		Property MemSize : Integer Read fMemSize Write fMemSize;
		Property DiskSize : Integer Read fDiskSize Write fDiskSize;
		Property MemMaxObjSize : Integer Read fMaxMemObjSize Write fMaxMemObjSize;
		Property DiskMaxObjSize : Integer Read fMaxDiskObjSize Write fMaxDiskObjSize;
	End;
	
	TLanCacheNode = Class(TXMLNode)
	Private
		fIP : String;
		fNetMask : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property IP : String Read fIP Write fIP;
		Property NetMask : String Read fNetMask Write fNetMask;
	End;

// DHCP server related
	
	TDHCPServerNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	End;

	TDHCPConfigNode = Class(TXMLNode)
	Private
		fDomainName,
		fNetmask : String;
		fDefLeaseTime,
		fMaxLeaseTime : Integer;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property DomainName : String Read fDomainName Write fDomainName;
		Property Netmask : String Read fNetmask Write fNetmask;
		Property DefLeaseTime : Integer Read fDefLeaseTime Write fDefLeaseTime;
		Property MaxLeaseTime : Integer Read fMaxLeaseTime Write fMaxLeaseTime;
	End;

	TDHCPNameServerNode = Class(TXMLNode)
	Private
		fIP : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property IP : String Read fIP Write fIP;
	End;

	TDHCPSubnetsNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	End;
	
	TDHCPSubnetsEntryNode = Class(TXMLNode)
	Private
		fNetwork,
		fNetmask,
		fRangeStart,
		fRangeEnd : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Network : String Read fNetwork Write fNetwork;
		Property Netmask : String Read fNetmask Write fNetmask;
		Property RangeStart : String Read fRangeStart Write fRangeStart;
		Property RangeEnd : String Read fRangeEnd Write fRangeEnd;
	End;

	TDHCPRouterEntryNode = Class(TXMLNode)
	Private
		fIP : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property IP : String Read fIP Write fIP;
	End;
	
	TDHCPHostsNode = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	End;

	TDHCPHostEntryNode = Class(TXMLNode)
	Private
		fHostName,
		fMAC,
		fIP : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property HostName : String Read fHostName Write fHostName;
		Property MAC : String Read fMAC Write fMAC;
		Property IP : String Read fIP Write fIP;
	End;

// ARP Related

	TARPTable = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	End;

	TDynamicARPTable = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
		Procedure OnUpdate(Var Message); Message 'update';
	End;
	
	TDynamicARPTableEntry = Class(TXMLNode)
	Private
		fMAC,
		fIP,
		fInterface,
		fKind : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property MAC : String Read fMAC Write fMAC;
		Property IP : String Read fIP Write fIP;
		Property Parent : String Read fInterface Write fInterface;
		Property Kind : String Read fKind Write fKind;
	End;

	TStaticARPTable = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	End;

	TStaticARPConfig = Class(TXMLNode)
	Private
		fMode : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;
	Published
		Property Mode : String Read fMode Write fMode;
	End;
	
	TStaticARPTableEntry = Class(TXMLNode)
	Private
		fMAC,
		fIP,
		fInterface : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property MAC : String Read fMAC Write fMAC;
		Property IP : String Read fIP Write fIP;
		Property Parent : String Read fInterface Write fInterface;
	End;
	
// Bridge related

	TBridges = Class(TXMLNode)
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	End;
	
	TBridgeEntry = Class(TXMLNode)
	Private
		fName : String;
		fStp : Boolean;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property Name : String Read fName Write fName;
		Property STP : Boolean Read fStp Write fStp;
	End;
	
	TBridgeSibbling = Class(TXMLNode)
	Private
		fName : String;
	Public
		Constructor Create(Const aOwner : TTreeNode); Override;
		Class Function RegisteredName : String; Override;	
	Published
		Property Name : String Read fName Write fName;
	End;

Implementation

// TDataBaseNode

Constructor TDataBaseNode.Create(Const aOWner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TInterfacesNode);
	Factory.Register(TScriptsNode);
	Factory.Register(TSystemNode);
	Factory.Register(TTemplatesNode);
	Factory.Register(TServicesNode);
	Factory.Register(TCacheNode);
	Factory.Register(TDHCPServerNode);
	Factory.Register(TARPTable);
	Factory.Register(TBridges);
End;

Procedure TDataBaseNode.SaveToFile(Const aFileName : String);
Var
	lIterator : TXMLAsTextIterator;
	lBuffer : TStringStream;
	lOutput : TFileStream;
Begin
	Try
		lIterator := TXMLAsTextIterator.Create;
		lIterator.Visit(Self);
		lBuffer := TStringStream.Create(lIterator.Output);
		If FileExists(aFileName) Then
			DeleteFile(aFileName);
		lOutput := TFileStream.Create(aFileName, fmCreate);
		lOutput.CopyFrom(lBuffer, lBuffer.Size);
	Finally
		FreeAndNil(lBuffer);
		FreeAndNil(lOutput);
		FreeAndNil(lIterator);
	End;
End;

Class Function TDataBaseNode.RegisteredName : String;
Begin
	Result := '$root$';
End;

// TInterfacesNode

Constructor TInterfacesNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(THardwareInterfaceNode);
	Factory.Register(TSoftwareInterfaceNode);
End;

Class Function TInterfacesNode.RegisteredName : String;
Begin
	Result := 'interfaces';
End;

// THardwareInterfaceNode

Constructor THardwareInterfaceNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(THardwareInterfaceNodeEntry);
End;

Class Function THardwareInterfaceNode.RegisteredName : String;
Begin
	Result := 'hardware';
End;

Procedure THardwareInterfaceNode.OnUpdate(Var Message);
Var
	lBuffer : TStringList;
	lCtrl : Integer;
	lDevice : THardwareInterfaceNodeEntry;
	lLine : String;
Begin
	Purge;
	Try
		lBuffer := TStringList.Create;
		lBuffer.LoadFromFile('/proc/net/dev');
		For lCtrl := 0 To lBuffer.Count - 1 Do
			lBuffer[lCtrl] := DelSpace1(lBuffer[lCtrl]);
		For lCtrl := 0 To lBuffer.Count - 1 Do
			lBuffer[lCtrl] := TrimSet(lBuffer[lCtrl], [ ' ' ]);
		lBuffer.Delete(0);
		lBuffer.Delete(0);
		For lCtrl := 0 To lBuffer.Count - 1 Do
		Begin
			lLine := lBuffer[lCtrl];
			lDevice := THardwareInterfaceNodeEntry.Create(Self);
			lDevice.Name := Copy2SymbDel(lLine, ':');
			lLine := TrimSet(lLine, [ ' ' ]);
			lDevice.RecvBytes := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvPackets := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvErrors := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvDrop := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvFIFO := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvFrame := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvCompressed := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.RecvMulticast := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendBytes := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendPackets := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendErrors := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendDrop := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendFIFO := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendFrame := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendCompressed := StrToInt(Copy2SymbDel(lLine, ' '));
			lDevice.SendMulticast := StrToInt(Copy2SymbDel(lLine, ' '));
		End;
	Finally
		FreeAndNil(lBuffer);
	End;
End;

// THardwareInterfaceNodeEntry

Constructor THardwareInterfaceNodeEntry.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	fName := 'device';
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fRecvBytes := 0;
	fSentBytes := 0;
	fRecvPackets := 0;
	fSentPackets := 0;
	fRecvErr := 0;
	fSentErr := 0;
	fRecvDrop := 0;
	fSentDrop := 0;
	fRecvFifo := 0;
	fSentFifo := 0;
	fRecvFrame := 0;
	fSentFrame := 0;
	fRecvCompressed := 0;
	fSentCompressed := 0;
	fRecvMulticast := 0;
	fSentMulticast := 0;
End;

Class Function THardwareInterfaceNodeEntry.RegisteredName : String;
Begin
	Result := 'device';
End;

// TSoftwareInterfaceNode

Constructor TSoftwareInterfaceNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TDHCPInterfaceNode);
	Factory.Register(TFixedIPInterfaceNode);
End;

Class Function TSoftwareInterfaceNode.RegisteredName : String;
Begin
	Result := 'software';
End;

// TDHCPInterfaceNode

Constructor TDHCPInterfaceNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fName := 'OPT' + IntToStr(GetMyIndex + 1);
	fRelated := 'rl0';
End;

Class Function TDHCPInterfaceNode.RegisteredName : String;
Begin
	Result := 'dhcp';
End;

// TFixedIPInterfaceNode

Constructor TFixedIPInterfaceNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fName := 'OPT' + IntToStr(GetMyIndex + 1);
	fRelated := 'rl0';
	fIP := '192.168.1.1';
	fNetmask := '255.255.255.0';
End;

Class Function TFixedIPInterfaceNode.RegisteredName : String;
Begin
	Result := 'fixedip';
End;

// TScriptsNode

Constructor TScriptsNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	Factory.Register(TScriptEntryNode);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
End;

Class Function TScriptsNode.RegisteredName : String;
Begin
	Result := 'scripts';
End;

// TScriptEntryNode

Constructor TScriptEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	fName := 'script' + IntToStr(GetMyIndex);
	ReadOnly := False;
End;

Class Function TScriptEntryNode.RegisteredName : String;
Begin
	Result := 'script';
End;

// TSystemNode

Constructor TSystemNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TEditorNode);
End;

Class Function TSystemNode.RegisteredName : String;
Begin
	Result := 'system';
End;

// TEditorNode

Constructor TEditorNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
End;

Class Function TEditorNode.RegisteredName : String;
Begin
	Result := 'editor';
End;

// TServicesNode

Constructor TServicesNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TServiceEntryNode);
End;

Class Function TServicesNode.RegisteredName : String;
Begin
	Result := 'services';
End;

// TServiceEntryNode

Constructor TServiceEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
End;

Class Function TServiceEntryNode.RegisteredName : String;
Begin
	Result := 'service';
End;

// TTemplatesNode
	
Constructor TTemplatesNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TTemplateEntryNode);
End;

Class Function TTemplatesNode.RegisteredName : String;
Begin
	Result := 'templates';
End;
	
// TTemplateEntryNode

Constructor TTemplateEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TTemplateEffectsNode);
End;

Class Function TTemplateEntryNode.RegisteredName : String;
Begin
	Result := 'template';
End;
	
// TTemplateEffectsNode = Class(TXMLNode)

Constructor TTemplateEffectsNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
End;

Class Function TTemplateEffectsNode.RegisteredName : String;
Begin
	Result := 'affects';
End;

// TCacheNode

Constructor TCacheNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TLanCacheNode);
	Factory.Register(TConfigCacheNode);
End;

Class Function TCacheNode.RegisteredName : String;
Begin
	Result := 'cache';
End;

// TConfigCacheNode

Constructor TConfigCacheNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fIP := '0.0.0.0';
	fHostname := 'opentik.org';
	fPort := 8080;
	fMemSize := 1024;
	fDiskSize := 256;
	fMaxMemObjSize := 16;
	fMaxDiskObjSize := 16;
End;

Class Function TConfigCacheNode.RegisteredName : String;
Begin
	Result := 'config';
End;

// TLanCacheNode

Constructor TLanCacheNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fIP := '0.0.0.0';
	fNetmask := '0.0.0.0';
End;

Class Function TLanCacheNode.RegisteredName : String;
Begin
	Result := 'lan';
End;

// TDHCPServerNode

Constructor TDHCPServerNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TDHCPConfigNode);
	Factory.Register(TDHCPSubnetsNode);
	Factory.Register(TDHCPHostsNode);
End;

Class Function TDHCPServerNode.RegisteredName : String;
Begin
	Result := 'dhcpserver';
End;

// TDHCPConfigNode

Constructor TDHCPConfigNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fDomainName := 'opentik.org';
	fNetmask := '255.255.255.0';
	fDefLeaseTime := 3600;
	fMaxLeaseTime := 7200;
	Factory.Register(TDHCPNameServerNode);
End;

Class Function TDHCPConfigNode.RegisteredName : String;
Begin
	Result := 'config';
End;

// TDHCPNameServerNode 

Constructor TDHCPNameServerNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fIP := '8.8.8.8';
End;

Class Function TDHCPNameServerNode.RegisteredName : String;
Begin
	Result := 'nameserver';
End;

// TDHCPSubnetsNode

Constructor TDHCPSubnetsNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TDHCPSubnetsEntryNode);
End;

Class Function TDHCPSubnetsNode.RegisteredName : String;
Begin
	Result := 'subnets';
End;

// TDHCPSubnetsEntryNode

Constructor TDHCPSubnetsEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fNetwork := '192.168.1.0';
	fNetmask := '255.255.255.0';
	fRangeStart := '192.168.1.100';
	fRangeEnd := '192.168.1.254';
	Factory.Register(TDHCPRouterEntryNode);
End;

Class Function TDHCPSubnetsEntryNode.RegisteredName : String;
Begin
	Result := 'subnet';
End;

// TDHCPRouterEntryNode

Constructor TDHCPRouterEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fIP := '192.168.1.1';	
End;

Class Function TDHCPRouterEntryNode.RegisteredName : String;
Begin
	Result := 'router';
End;
	
// TDHCPHostsNode
	
Constructor TDHCPHostsNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TDHCPHostEntryNode);
End;

Class Function TDHCPHostsNode.RegisteredName : String;
Begin
	Result := 'hosts';
End;

// TDHCPHostEntryNode

Constructor TDHCPHostEntryNode.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fHostName := 'opentik.org';
	fMAC := '00:00:00:00:00:00';
	fIP := '192.168.1.2';
End;

Class Function TDHCPHostEntryNode.RegisteredName : String;
Begin
	Result := 'host';
End;

// TARPTable

Constructor TARPTable.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TDynamicARPTable);
	Factory.Register(TStaticARPTable);
End;

Class Function TARPTable.RegisteredName : String;
Begin
	Result := 'arp';
End;

// TDynamicARPTable

Constructor TDynamicARPTable.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TDynamicARPTableEntry);
End;

Class Function TDynamicARPTable.RegisteredName : String;
Begin
	Result := 'dynamic';
End;

Procedure TDynamicARPTable.OnUpdate(Var Message);
Var
	lBuffer : TStringList;
	lCtrl : Integer;
	lEntry : TDynamicARPTableEntry;
	lLine : String;
Begin
	Purge;
	Try
		lBuffer := TStringList.Create;
		lBuffer.LoadFromFile('/proc/net/arp');
		For lCtrl := 0 To lBuffer.Count - 1 Do
			lBuffer[lCtrl] := DelSpace1(lBuffer[lCtrl]);
		For lCtrl := 0 To lBuffer.Count - 1 Do
			lBuffer[lCtrl] := TrimSet(lBuffer[lCtrl], [ ' ' ]);
		lBuffer.Delete(0);
		For lCtrl := 0 To lBuffer.Count - 1 Do
		Begin
			lLine := lBuffer[lCtrl];
			lEntry := TDynamicARPTableEntry.Create(Self);
			lEntry.IP := Copy2SymbDel(lLine, ' ');
			Copy2SymbDel(lLine, ' ');
			lEntry.Kind := Copy2SymbDel(lLine, ' ');
			If lEntry.Kind = '0x2' Then
				lEntry.Kind := 'Dynamic'
			Else If lEntry.Kind = '0x6' Then
				lEntry.Kind := 'Static'
			Else
				lEntry.Kind := 'unknown';
			lEntry.Mac := Copy2SymbDel(lLine, ' ');
			Copy2SymbDel(lLine, ' ');
			lEntry.Parent := Copy2SymbDel(lLine, ' ');
		End;
	Finally
		FreeAndNil(lBuffer);
	End;
End;

// TDynamicARPTableEntry

Constructor TDynamicARPTableEntry.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fMAC := '00:00:00:00:00:00';
	fIP := '0.0.0.0';
	fInterface := 'rl0';
	fKind := 'unknown';
End;

Class Function TDynamicARPTableEntry.RegisteredName : String;
Begin
	Result := 'mapping';
End;

// TStaticARPTable

Constructor TStaticARPTable.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := True;
	Factory.Register(TStaticARPConfig);
	Factory.Register(TStaticARPTableEntry);
End;

Class Function TStaticARPTable.RegisteredName : String;
Begin
	Result := 'static';
End;
	
// TStaticARPConfig

Constructor TStaticARPConfig.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fMode := 'dynamic';
End;

Class Function TStaticARPConfig.RegisteredName : String;
Begin
	Result := 'config';
End;

// TStaticARPTableEntry
	
Constructor TStaticARPTableEntry.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fMAC := '00:00:00:00:00:00';
	fIP := '0.0.0.0';
	fInterface := 'rl0';
End;

Class Function TStaticARPTableEntry.RegisteredName : String;
Begin
	Result := 'mapping';
End;

// TBridges

Constructor TBridges.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TBridgeEntry);
End;

Class Function TBridges.RegisteredName : String;
Begin
	Result := 'bridges';
End;


// TBridgeEntry

Constructor TBridgeEntry.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	Factory.Register(TBridgeSibbling);
	fName := 'bridge' + IntToStr(GetMyIndex + 1);
	fSTP := False;
End;

Class Function TBridgeEntry.RegisteredName : String;
Begin
	Result := 'bridge';
End;


// TBridgeSibbling
	
Constructor TBridgeSibbling.Create(Const aOwner : TTreeNode);
Begin
	Inherited Create(aOwner);
	AddCapability('focusable');
	AddCapability('TQuitCommand');
	AddCapability('TPrintCommand');
	AddCapability('TListCommand');
	AddCapability('TAddCommand');
	AddCapability('TParseTemplateCommand');
	AddCapability('TSaveCommand');
	AddCapability('TUpCommand');
	AddCapability('TDeleteCommand');
	AddCapability('TSetCommand');
	AddCapability('TPutCommand');
	AddCapability('TExecuteCommand');
	AddCapability('TEditCommand');
	AddCapability('TExportCommand');
	AddCapability('TCommitCommand');
	AddCapability('TUpdateCommand');
	AddCapability('TLoadFromTextFile');
	ReadOnly := False;
	fName := 'rl0';
End;

Class Function TBridgeSibbling.RegisteredName : String;
Begin
	Result := 'interface';
End;

End.
